NOTE: This Technical Q&A has been retired. Please see the Technical Q&As page for current documentation.

Technical Q&A TB06
Creating a Menu with an Icon as its Title

Q How do I create a menu with an icon as its title, such as AppleScript(TM) and other products use?

A The menu data for the menu title must be 0x0501<handle> where <handle> is replaced by the the results of calling GetIconSuite(). An example snippet of code follows. This snippet assumes that the menu title is already 5 bytes long.
void ChangeToIconMenu()
{
                Handle              theIconSuite = nil;
                MenuHandle         menuHandle;

    GetIconSuite(&theIconSuite, cIcon, svAllSmallData);
    if (theIconSuite)
    {
        menuHandle = GetMenuHandle(mIcon);
        if (menuHandle)
        {
            // second byte must be a 1, followed by the icon suite handle
            (**menuHandle).menuData[1] = 0x01;
            *((long *)&((**menuHandle).menuData[2])) = (long)theIconSuite;
            // update display (typically you do this on startup)
            DeleteMenu(mIcon);
            InsertMenu(menuHandle, 0);
            InvalMenuBar();
        }
    }
}

[May 01 1995]


Developer Documentation | Technical Notes | Development Kits | Sample Code